import React, { Component } from 'react';
import { Switch, Route, Redirect,Link } from 'react-router-dom'

import fetchUtil from './utils/fetchUtil'

import Pay from './page/pay'
import PaySuccess from './page/paySuccess'
import MapList from './page/maplist'
import Me from './page/me'
import TradeList from './page/trade'
import ExChange from './page/exchange'
import QRCard from './page/qrcard'
import QRCardWithState from './page/qrcardwithstate'

const routeChange = () => {
    const data = {
        apilist:'openLocation',
        url:'http://jyx.7chejian.com'
    }
    fetchUtil.post('/getJsConfig',data)
        .then((rs) => {
            if (rs.success){
                window.wx.config(rs.data);
            } else {
                   
            }
        }, e => {
         
        });
}

const Main = () => (
        <Switch>
            <Route exact path='/pay/:equipNo' component={Pay}/>
            <Route exact path='/maplist' onChange={routeChange} component={MapList}/>
            <Route exact path='/me'  component={Me}/>
            <Route exact path='/tradelist' component={TradeList}/>
            <Route exact path='/success' component={PaySuccess}/>
            <Route exact path='/exchange' component={ExChange}/>
            <Route exact path='/qrcard/:id' component={QRCard}/>
            <Route exact path='/qrcard/:id/:cardNo' component={QRCardWithState}/>
        </Switch>
);

export default Main;


